package cn.itcast.controller;

import cn.itcast.bean.HotWords;
import cn.itcast.redis.StringRedisService;
import cn.itcast.service.IDubboDemoService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.List;

/**
 * @Description :
 * @Auther : zj
 * @Date : 2019/1/21 14:30
 */
@Controller
@RequestMapping
public class TestController {

    @Autowired
    private IDubboDemoService dubboDemoService;

    @Autowired
    private StringRedisService redisService;

    @RequestMapping("/testTwo/{ids}")
    @ResponseBody
    public List<HotWords> testTwo(@PathVariable Integer ids) {
        System.out.println("请求二");
        return dubboDemoService.hotwordsList(ids);
    }

    @RequestMapping("/testredis/{ids}")
    @ResponseBody
    public String testredis(@PathVariable Integer ids) {
        redisService.set("1",ids.toString());
        return "添加成功";
    }

    @RequestMapping("/get/{key}")
    @ResponseBody
    public String get(@PathVariable String key) {
       return dubboDemoService.getRedis(key);
    }
}
